package com.jnetwork.servlet.idea;

import java.io.IOException;
import java.util.Collection;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.jnetwork.modelo.CentroFormacion;
import com.jnetwork.modelo.Idea;
import com.jnetwork.negocio.GestionCentroFormacion;
import com.jnetwork.negocio.GestionReporteIdeas;

/**
 * Servlet implementation class IdeaReporteServlet
 */
@WebServlet("/IdeaReporteServlet")
public class IdeaReporteServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private String titulo;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public IdeaReporteServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
		String titulo = request.getParameter("titulo");
		String descripcion = request.getParameter("descripcion");
		String key1 = request.getParameter("key1");
		String key2 = request.getParameter("key2");
		String key3 = request.getParameter("key3");
		String key4 = request.getParameter("key4");
		
		GestionReporteIdeas negocio = new GestionReporteIdeas();
		try {
			Collection<Idea> lista = negocio.buscarIdea(titulo,descripcion, key1, key2,  key3,  key4);
			request.setAttribute("Idea", lista);
			
			
			RequestDispatcher rd = request.getRequestDispatcher("reporte_ideas.jsp");
			rd.forward(request, response);
			
		} catch (Exception e) {
			e.printStackTrace();
			request.setAttribute("ERROR_MENSAJE", e.getMessage());
			RequestDispatcher rd = request
					.getRequestDispatcher("reporte_ideas.jsp");
			rd.forward(request, response);
		}
		
		

	}
}

